﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web
{
    public partial class WebShopInfo : System.Web.UI.Page
    {
        public Model.tb_goods model = new Model.tb_goods();

        public string sellNums = "0";
        public string callNums = "0";
        public List<Model.view_calls> call_list = new List<Model.view_calls>();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["Id"]==null)
            {
                 Response.Write("<script>alert('请先选择商品！');window.location.href='default.aspx';</script>");
            }
            else
            {
               
                int Id = Convert.ToInt32(Request.QueryString["Id"]);
                 var olist=Common.SqlExption.GetList<Model.tb_order>().Where(c=>c.gid.Equals(Id)).ToList();
                model = Common.SqlExption.GetList<Model.tb_goods>().FirstOrDefault(c => c.Id.Equals(Id));
                var list = Common.SqlExption.GetList<Model.tb_order>().ToList();
                var selllist = list.Where(c => !c.status.Equals(1) && c.status.Equals(6)&&c.gid.Equals(Id)).ToList();
                sellNums = selllist.Count().ToString();
                var callList = list.Where(c => c.status.Equals(5)&&c.gid.Equals(Id)).ToList();
                callNums = callList.Count().ToString();
                foreach (var item in olist){
                    var callmodel = Common.SqlExption.GetList<Model.tb_call_msg>().FirstOrDefault(c => c.order_number.Equals(item.order_number));
                    if (callmodel!=null)
                    {
                        Model.view_calls cmodel = new Model.view_calls()
                        {
                            callMsg = callmodel.call_msg,
                            contents = callmodel.contents,
                            dates = callmodel.create_time.ToString("MM/dd")
                        };
                        call_list.Add(cmodel);
                    }
                  

                }

               
            }
        }
    }
}